class Account {
  double amount;
  synchronized void 
    transfer(Account ac, double mn){
      this.amount = this.amount - mn;
      ac.amount = ac.amount + mn; 
    }
  ...}
class TranT() extends Thread {
  Account a1, a2;  double val;
  void run() {
    a1.transfer(a2, val);
  }}
void main(String[] args) {
  Account acc1, acc2;...
  double total = acc1.amount + acc2.amount;
  TranT t1 = new TranT(acc1, acc2, 10);
  TranT t2 = new TranT(acc2, acc1, 3);
  t1.start(); t2.start();
  Assert.assertEqual(total, 
    acc1.amount + acc2.amount);
}